# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=ddosify
pkgver=v2.6.0.r31.g0131056
pkgrel=1
epoch=1
pkgdesc='High-performance load testing tool, written in Golang.'
arch=('x86_64' 'aarch64')
groups=('blackarch' 'blackarch-dos' 'blackarch-misc')
url='https://github.com/ddosify/ddosify'
license=('AGPL')
depends=('glibc')
makedepends=('git' 'go')
source=("git+https://github.com/ddosify/$pkgname.git")
sha256sums=('SKIP')

pkgver() {
  cd $pkgname

  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g' |
  sed 's|selfhosted.|v|g'
}

build() {
  cd "$pkgname/${pkgname}_engine"

  GOPATH="$srcdir" go mod download
  GOPATH="$srcdir" go build \
    -trimpath \
    -buildmode=pie \
    -mod=readonly \
    -modcacherw \
    -ldflags "-s -w" \
    -o $pkgname .

}

package() {
  cd "$pkgname/${pkgname}_engine"

  install -Dm 755 $pkgname "$pkgdir/usr/bin/$pkgname"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" "$srcdir/$pkgname/"*.md

  install -Dm 644 "$srcdir/$pkgname/LICENSE" \
    "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

